using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;

public class httprequ : MonoBehaviour
{
    // Start is called before the first frame update
    IEnumerator Start()
    {
        string url = "http://127.0.0.1:8000/items/123?q=123"; // 替换为你的URL
        using (UnityWebRequest webRequest = UnityWebRequest.Get(url))
        {
            // 发送请求并等待响应
            yield return webRequest.SendWebRequest();

            // 检查是否有错误发生
            if (webRequest.result != UnityWebRequest.Result.Success)
            {
                Debug.LogError("Error: " + webRequest.error);
            }
            else
            {
                // 获取返回值
                string responseText = webRequest.downloadHandler.text;
                Debug.Log("Response: " + responseText);
            }
        }
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}
